package com.kedacom.testlego.view.activity

import android.content.Intent
import android.net.Uri
import android.view.View
import com.kedacom.dkvideoplayer.FullScreenActivity
import com.kedacom.gsyvideoplayer.SuperVideoViewDemoActivity
import com.kedacom.testlego.R
import com.kedacom.testlego.databinding.ActivityMainBinding
import com.kedacom.testlego.viewmodel.MainViewModel
import com.kedacom.widget.mediapicker.Util


class MainActivity : BaseActivity<ActivityMainBinding, MainViewModel>() {

    override fun getContentViewId() = R.layout.activity_main

    val localPath = "/storage/emulated/0/Quark/Download/210810094303VID_20210810_093643.mp4"

    //    val videoUrl = "http://vfx.mtime.cn/Video/2019/03/12/mp4/190312143927981075.mp4"
// https证书异常的视频 （java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.）
    val videoUrl =
        "https://192.168.20.180/pacc/attachment/v1/paccFileDownload?filePath=2021-08-26/210826145655local_video.mp4&optType=online"
    // MediaPlayer: error (1, -1004)，视频地址支持下载，不支持在线播放
//    val videoUrl = "http://192.168.20.180/pacc/attachment/v1/paccFileDownload?filePath=2021-08-16/210816092644210810094303VID_20210810_093643.mp4"


    fun video1(v: View?) {
        startActivity(Intent(this, VideoPlayActivity::class.java).apply {
            putExtra("videoUrl", videoUrl)
        })
    }

    /**
     * 同事（baoshun）封装的TV播放器（SuperVideoView）
     * 基于MediaPlayer
     * 《电视盒 点播系统》（VodSystem）中有使用
     *
     * @param v View?
     */
    fun video2(v: View?) {
        startActivity(Intent(this, SuperVideoViewDemoActivity::class.java))
    }

    /**
     * Lego封装的播放器(PlayVideoActivity)
     * 基于MediaPlayer
     * @param v View?
     */
    fun video3(v: View?) {
//        startActivity(Intent(this, PlayVideoActivity::class.java))
        Util.openPlayVideoActivity(Uri.parse(videoUrl), this, "Lego封装的播放器")
    }

    /**
     * 饺子播放器
     * @param v View?
     */
    fun video4(v: View?) {
        //layout视图播放
        startActivity(Intent(this, JzVideoPlayActivity2::class.java).apply {
            putExtra("videoUrl", videoUrl)
        })

//        //直接全屏播放，不支持设置播放内核；可以依赖并修改源码，自己扩展实现。
//        JzvdStd.startFullscreenDirectly(
//            this,
//            JzvdStd::class.java, videoUrl, "直接全屏播放"
//        )
    }

    /**
     * DK播放器
     * @param v View?
     */
    fun video5(v: View?) {
//        FullScreenActivity.playLocalVideo(this, localPath, "视频名称")
        FullScreenActivity.playOnlineVideo(this, videoUrl, "DK播放器")
    }


    /**
     * ExoPlayer库的使用
     * @param v View?
     */
    fun video6(v: View?) {
        startActivity(Intent(this, ExoVideoPlayActivity::class.java).apply {
            putExtra("videoUrl", videoUrl)
        })
    }
}
